package mrpheu.demo.server.classes;

import java.util.Map;

import mrpheu.demo.server.bean.MessageItem;
import mrpheu.demo.server.constants.MessageItemType;
import mrpheu.demo.server.implement.MessageStrategyBroadcast;
import mrpheu.demo.server.implement.MessageStrategyPeer;
import mrpheu.demo.server.interfaces.IMessageStrategy;
import mrpheu.demo.server.interfaces.IZoneClient;

public class MessageStrategyFactory {
    
    /**
     * Not use client 
     * @param clientList
     * @param messageItem
     * @return
     */
    public static IMessageStrategy createMessageStrategy(Map<Integer, IZoneClient> clientList, MessageItem messageItem) {
        IMessageStrategy strategy = null;
        if(messageItem != null) {
            MessageItemType messageItemType = messageItem.getMessageType();
            switch (messageItemType) {
                case BROADCAST:
                    strategy = new MessageStrategyBroadcast(clientList, messageItem);
                    break;
                case PEER:
                    strategy = new MessageStrategyPeer(clientList, messageItem);
                    break;
                default:
                    break;
            }
        }
        return strategy;
    }
}
